package com.burgeon.backend.SHOPBACKEND.rest.invite;
/**
 * 删除优惠券
 */

import com.burgeon.backend.Rest.base.RESTBase;
import org.json.JSONArray;
import org.springframework.util.MultiValueMap;

import java.util.HashMap;

public class DeleteExpressionsData extends RESTBase {

    private String ip;
    private String account;
    private String password;

    public DeleteExpressionsData(String ip, String account, String password) {
        this.ip = ip;
        this.account = account;
        this.password = password;
    }

    /**
     * 发送并接收字符
     */

    public void getData(String id) throws Exception {
        String url = "http://" + ip + "/servlets/binserv/Rest";

        String str = RESULT(Data(id), url);

        String code = new JSONArray(str).getJSONObject(0).getString("code");

        if (!"0".equals(code)) {
            throw new Exception("删除失败");
        }
    }

    private MultiValueMap Data(String id) {

        HashMap params = new HashMap();

        params.put("ID",id);//券号

        params.put("partial_update", "true");

        params.put("table", "APP_VIP_RVISITLAE");//表名

        return DATA("ObjectDelete", params, account, password);
    }

    public static void main(String[] args) {
        DeleteExpressionsData g = new DeleteExpressionsData("39.100.45.8:55322", "nea@burgeon.com.cn", "123");
        try {
            g.getData("123");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
